class Solution {
public:
    bool isPalindrome(string s)
    {
        int begin = 0;//
        int end = s.size() - 1;
        char tmpb, tmpe;
        while (begin < end)
        {
            while (begin < end && (!isalpha(s[begin]) && !isdigit(s[begin])))
            {
                ++begin;
            }
            if (isupper(s[begin]))
            {
                tmpb = tolower(s[begin]);
            }
            else
            {
                tmpb = s[begin];
            }
            while (begin < end && (!isalpha(s[end]) && !isdigit(s[end])))
            {
                --end;
            }
            if (isupper(s[end]))
            {
                tmpe = tolower(s[end]);
            }
            else
            {
                tmpe = s[end];
            }
            if (tmpb != tmpe)
            {
                return false;
            }
            ++begin;
            --end;
        }
        return true;
    }
};